<% permitted_params = params.permit(*filtering_params) %>

<div data-hook="search_results">
  <% if @products.empty? %>
    <% if permitted_params[:keywords].present? && permitted_params.to_h.one? %>
      <%= render 'spree/products/no_results' %>
    <% else %>
      <%= render 'spree/products/no_results_with_filters', permitted_params: permitted_params %>
    <% end %>
  <% else %>
    <% if params[:keywords] %>
      <div class="container d-md-flex pt-md-5">
        <div class="plp-results-text text-uppercase mx-md-auto py-md-5">
          <%= "#{@products.total_count} #{Spree.t('plp.results_for')} '#{params[:keywords].upcase}'" %>
        </div>
      </div>
    <% elsif not @taxon %>
      <div id="no-taxon-banner">
        <div class="container">
          <%= lazy_image(
            src: asset_path('homepage/products.jpg'),
            alt: 'products-banner',
            width: 1110,
            height: 300,
            class: 'w-100 d-none d-md-block'
          ) %>
        </div>
      </div>
    <% end %>

    <%= render 'spree/products/filter_and_sort_mobile_buttons' %>
    <%= render 'spree/products/sort_desktop', permitted_params: permitted_params %>
    <div class="container mb-3 d-md-flex">
      <%= render 'spree/products/filters_desktop', permitted_params: permitted_params %>
      <%= render 'spree/shared/products', products: @products %>
    </div>
  <% end %>
</div>

<%= render 'spree/products/filters_mobile', permitted_params: permitted_params %>
<%= render 'spree/products/sort_mobile', permitted_params: permitted_params %>

<% cache cache_key_for_products(@products, 'json-ld') do %>
  <%= products_structured_data(@products) %>
<% end %>
